﻿#pragma once
#include "DelegateCommand.g.h"


namespace winrt::NovelReader::implementation
{
	struct DelegateCommand : DelegateCommandT<DelegateCommand>
	{
		using CanExecuteChangedHandler = winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>;

		DelegateCommand() = default;
		DelegateCommand(winrt::NovelReader::ExecuteHandler const& executeHandler, winrt::NovelReader::CanExecuteHandler const& canExecuteHandler);

		winrt::event_token CanExecuteChanged(CanExecuteChangedHandler const& handler);
		void CanExecuteChanged(winrt::event_token const& token) noexcept;

		bool CanExecute(winrt::Windows::Foundation::IInspectable const& parameter);
		void Execute(winrt::Windows::Foundation::IInspectable const& parameter);

	private:
		winrt::NovelReader::ExecuteHandler m_executeHandler {nullptr}; 
		winrt::NovelReader::CanExecuteHandler m_canExecuteHandler {nullptr}; 
		winrt::event<CanExecuteChangedHandler> m_canExecuteChanged; 
		bool m_canExecute {true}; 
	};
}
namespace winrt::NovelReader::factory_implementation
{
	struct DelegateCommand : DelegateCommandT<DelegateCommand, implementation::DelegateCommand>
	{
	};
}
